package com.pavel.taskig.client;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;

public class Task {
	private String name;
	private String description;
	private Date startDate;
	private Date completionDate;
	private Status status;
	private Date dueDate;
	private Long estimate;
	private Collection<Task> dependencies;
	private List<Task> subTasks;

	public void addSubTask(Task task) {
		if (subTasks == null) {
			subTasks = new ArrayList<Task>();
		}
		subTasks.add(task);
	}

	public void removeSubTask(Task task) {
		if (subTasks != null && subTasks.contains(task)) {
			subTasks.remove(task);
		}
	}

	public void addDependency(Task task) {
		if (dependencies == null) {
			dependencies = new ArrayList<Task>();
		}
		dependencies.add(task);
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setCompletionDate(Date completionDate) {
		this.completionDate = completionDate;
	}

	public Date getCompletionDate() {
		return completionDate;
	}

	public void setStatus(Status status) {
		this.status = status;
	}

	public Status getStatus() {
		return status;
	}

	public void setDueDate(Date dueDate) {
		this.dueDate = dueDate;
	}

	public Date getDueDate() {
		return dueDate;
	}

	public void setEstimate(Long estimate) {
		this.estimate = estimate;
	}

	public Long getEstimate() {
		return estimate;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getDescription() {
		return description;
	}

	@Override
	public String toString() {
		return "Task [completionDate=" + completionDate + ", dependencies="
				+ dependencies + ", description=" + description + ", dueDate="
				+ dueDate + ", estimate=" + estimate + ", name=" + name
				+ ", startDate=" + startDate + ", status=" + status
				+ ", subTasks=" + subTasks + "]";
	}

}
